Rinku Chacko's profile

Visual Studio code- Pacman.cpp

Pacman.cpp

#include "Pacman.h"
// Fill out your copyright notice in the Description page of Project Settings.
#include "Food.h"
// Sets default values
APacman::APacman()
{
    // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void APacman::BeginPlay()
{
    Super::BeginPlay();
    OnActorBeginOverlap.AddDynamic(this, &APacman::OnOverlapBegin);
    UE_LOG(LogTemp, Warning, TEXT("please"));
}

void APacman::OnConstruction(const FTransform& Transform)
{
    Super::OnConstruction(Transform);
    //OnActorBeginOverlap.AddDynamic(this, &APacman::OnOverlapBegin);
}
// Called every frame
void APacman::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    if (!Frozen) {
        AddMovementInput(GetActorForwardVector());
    }
}
// Called to bind functionality to input
void APacman::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void APacman::SetDirection(const FVector Direction)
{
    if (Direction == FVector::UpVector) {
        SetActorRotation(FRotator(0, 270, 0));
    }
    else if (Direction == FVector::DownVector) {
        SetActorRotation(FRotator(0, 90, 0));
    }
    else if (Direction == FVector::RightVector) {
        SetActorRotation(FRotator(0, 0, 0));
    }
    else if (Direction == FVector::LeftVector) {
        SetActorRotation(FRotator(0, 180, 180));
    }
}
void APacman::OnOverlapBegin(AActor* PlayerActor, AActor* OtherActor)
{
    
    if (OtherActor->ActorHasTag("Foodie.Regular")) {
        Cast<AFood>(OtherActor)->Consume();
        
        UE_LOG(LogTemp, Warning, TEXT("Score"));
    }
    
}
Visual Studio code- Pacman.cpp
Published:

Visual Studio code- Pacman.cpp

Published:

Creative Fields